<template>
  <div>
    <div class="product-contain ">
      <div class="productInfo" v-for="(item, index) in goodsList" @click="handleClick(item.id)" :key="index">
        <van-image lazy-load :src="item.list_pic_url"/>
        <div>
          <span>{{ item.name }}</span>
          <p>{{ item.retail_price }}￥</p>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
//相关产品页
export default {
  name: "Products",
  props: ['goodsList'],
  data() {
    return {};
  },
  methods: {
    handleClick(id) {
      this.$router.push(`productDetail?id=${id}`);
      if (this.$route.path === '/productDetail') {
        this.$router.go(0);
      }
    }
  }
}
</script>

<style scoped lang="less">
.product-contain {
  display: flex;
  flex-wrap: wrap;
  width: 100%;

  .productInfo {
    background-color: #fff;
    width: 50%;

    div {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>
